/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author frazz
 */
@Entity
@Table(name = "acquisto")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Acquisto.findAll", query = "SELECT a FROM Acquisto a"),
    @NamedQuery(name = "Acquisto.findByIdacquisto", query = "SELECT a FROM Acquisto a WHERE a.idacquisto = :idacquisto"),
    @NamedQuery(name = "Acquisto.findByData", query = "SELECT a FROM Acquisto a WHERE a.data = :data"),
    @NamedQuery(name = "Acquisto.findByPrezzo", query = "SELECT a FROM Acquisto a WHERE a.prezzo = :prezzo")})
public class Acquisto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idacquisto")
    private Integer idacquisto;
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "prezzo")
    private Double prezzo;
    @JoinColumn(name = "prodotto", referencedColumnName = "idprodotto")
    @ManyToOne
    private Prodotto prodotto;
    @JoinColumn(name = "cliente", referencedColumnName = "username")
    @ManyToOne
    private Utente cliente;

    public Acquisto() {
    }

    public Acquisto(Integer idacquisto) {
        this.idacquisto = idacquisto;
    }

    public Integer getIdacquisto() {
        return idacquisto;
    }

    public void setIdacquisto(Integer idacquisto) {
        this.idacquisto = idacquisto;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Double getPrezzo() {
        return prezzo;
    }

    public void setPrezzo(Double prezzo) {
        this.prezzo = prezzo;
    }

    public Prodotto getProdotto() {
        return prodotto;
    }

    public void setProdotto(Prodotto prodotto) {
        this.prodotto = prodotto;
    }

    public Utente getCliente() {
        return cliente;
    }

    public void setCliente(Utente cliente) {
        this.cliente = cliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idacquisto != null ? idacquisto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Acquisto)) {
            return false;
        }
        Acquisto other = (Acquisto) object;
        if ((this.idacquisto == null && other.idacquisto != null) || (this.idacquisto != null && !this.idacquisto.equals(other.idacquisto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jpa.Acquisto[ idacquisto=" + idacquisto + " ]";
    }
    
}
